package 创建者模式.singleton.懒汉式_线程安全;

/**
 * @Description TODO
 * @Author shallow
 * @Date 2023/3/1 14:12
 */

public class Singleton {
    //私有化构造函数
    private Singleton (){}
    //定义私有成员Singleton类型的成员变量
    private static Singleton instance;
    //外部调用接口
    private static synchronized  Singleton getInstance(){
        if(instance == null){
            instance = new Singleton();
        }
        return instance;
    }
}
